package com.example.train.business.controller;

import com.example.train.business.req.StationQueryReq;
import com.example.train.business.resp.StationQueryResp;
import com.example.train.business.service.StationService;
import com.example.train.common.resp.CommonResp;
import com.example.train.common.resp.PageResp;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/station")

public class StationController {

    @Resource
    private StationService stationService;


    /**
     * 查询当前会员下乘客信息列表的controller类，用于调用service
     * 注意GetMapping不用requestBody注解，否则后端接受不到数据
     * @param @VALID StationQueryReq
     * @return CommonResp<PageResp<StationQueryResp>>
     */
    @GetMapping("/query-list")
    public CommonResp<PageResp<StationQueryResp>> queryList(@Valid StationQueryReq req) {
        PageResp<StationQueryResp> list = stationService.queryList(req);
        return new CommonResp<>(list);
    }


    /**
     * 查询车站功能的controller层接口
     * @return CommonResp<List<StationQueryResp>>
     */
    @GetMapping("/query-all")
    public CommonResp<List<StationQueryResp>> queryList() {
        List<StationQueryResp> list = stationService.queryAll();
        return new CommonResp<>(list);
    }


}

